const Generator = require('yeoman-generator');

module.exports = class extends Generator {
    prompting() {
        return this.prompt([{
                type: "input", //接收用户输入
                name: "name", //项目名字
                message: "Your project name", //提问信息
                default: this.appname //默认名字
            }])
            .then(answer => {
                this.answer = answer //挂载到this上面
            })
    }
    writing() {
        //项目文件路径
        let templates = [
            "./public/favicon.ico",
            "./public/index.html",
            "./.editorconfig",
            "./.gitignore",
            "./babel.config.js",
            "./package.json",
            "./package-lock.json",
            "./README.md",
            "./tsconfig.json",
            "./src/assets/logo.png",
            "./src/components/HelloWorld.vue",
            "./src/router/index.ts",
            "./src/store/index.ts",
            "./src/views/About.vue",
            "./src/views/Home.vue",
            "./src/App.vue",
            "./src/main.ts",
            "./src/shims-tsx.d.ts",
            "./src/shims-vue.d.ts",
        ]
        templates.forEach(item => { //通过forEach遍历
            this.fs.copyTpl(
                this.templatePath(item), this.destinationPath(item), this.answer
            )
        })
    }
}